﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.XCMG.Util;

namespace PMS.XCMG.Entity
{
    /// <summary>
    /// CF_District
    /// </summary>
    public partial class CF_District : BaseEntity
    {
        /// <summary>
        /// 地址编码
        /// </summary>
        public string Code { get; set; }

        /// <summary>
        /// 名称
        /// </summary>
        public string Name { get; set; }
        /// <summary>
        /// 级别
        /// </summary>
        public string Level { get; set; }
        /// <summary>
        /// 父节点
        /// </summary>
        public string ParentId { get; set; }
        /// <summary>
        /// 城市编码
        /// </summary>
        public string CityCode { get; set; }
    }

    public partial class CF_District : BaseEntity
    {
    }

    /// <summary>
    /// 实体配置
    /// OnModelCreating
    /// </summary>
    public class CF_DistrictTypeConfig : BaseEntityTypeConfig<CF_District>, IEntityTypeConfiguration<CF_District>
    {
        public override void Configure(EntityTypeBuilder<CF_District> builder)
        {
            base.Configure(builder);

            #region 主外键关系
            #endregion

            #region 字段属性:最大长度,是否必需,默认值
            builder.Property(p => p.Code).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.Name).HasMaxLength(EntityDefinition.DefMiddleColLen).IsRequired();
            builder.Property(p => p.Level).HasMaxLength(EntityDefinition.DefSmallColLen).IsRequired();
            builder.Property(p => p.ParentId).HasMaxLength(EntityDefinition.DefSmallColLen);
            builder.Property(p => p.CityCode).HasMaxLength(EntityDefinition.DefSmallColLen);
            #endregion

            #region 备注
            builder.HasComment("全国地址信息");
            builder.Property(p => p.Code).HasComment("地址编码");
            builder.Property(p => p.Name).HasComment("名称");
            builder.Property(p => p.Level).HasComment("级别");
            builder.Property(p => p.ParentId).HasComment("父节点");
            builder.Property(p => p.CityCode).HasComment("城市编码");
            #endregion

            #region 种子数据
            #endregion
        }
    }
}
